//
//  UIImage+LBPhotoBrowser.m
//  app
//
//  Created by LINAICAI on 2017/5/11.
//  Copyright © 2017年 NAICAI LI. All rights reserved.
//

#import "UIImage+LBPhotoBrowser.h"

@implementation UIImage (LBPhotoBrowser)
- (CGRect)lb_frameWithScreenWidth{
    CGFloat screenW = UIScreen.mainScreen.bounds.size.width;
    
    CGFloat screenH = UIScreen.mainScreen.bounds.size.height;
    
    
    CGSize size = [self lb_sizeWithScreenWidth];
    
    CGFloat x = (screenW - size.width) * 0.5;
    CGFloat y = (screenH - size.height) * 0.5;
    NSLog(@"lb_frameWithScreenWidth=%f,%f",size.width,size.height);
    return CGRectMake(x, y, size.width, size.height);
}
- (CGSize)lb_sizeWithScreenWidth{
    CGFloat width = self.size.width;
    CGFloat height = self.size.height;
    
    CGFloat screenW = UIScreen.mainScreen.bounds.size.width;
    
    if (width > screenW) {
        
        width = screenW;
        height = width * self.size.height / self.size.width;
        
    }
    NSLog(@"lb_sizeWithScreenWidth=%f,%f",width,height);
    return CGSizeMake(width, height);
}

@end
